package com.revenant.driver.ui.activity;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import com.revenant.driver.R;
import com.revenant.driver.base.BaseActivity;
import com.revenant.driver.bean.ShipperBean.EmptyDetailBean;
import com.revenant.driver.utils.GsonUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

import static com.revenant.driver.utils.Constants.Get_Empty_Details;

public class DriverEmptyDetailActivity extends BaseActivity {
    @BindView(R.id.strat_place)
    TextView stratPlace;
    @BindView(R.id.end_place)
    TextView endPlace;
    @BindView(R.id.car_num)
    TextView carNum;
    @BindView(R.id.car_type)
    TextView carType;
    @BindView(R.id.car_pho)
    TextView carPho;
    @BindView(R.id.car_name)
    TextView carName;
    @BindView(R.id.driver_info_click)
    TextView driverInfoClick;
    @BindView(R.id.shippername)
    ImageView shippername;
    @BindView(R.id.commentscore)
    TextView commentscore;
    @BindView(R.id.show_driver_info)
    LinearLayout showDriverInfo;
    @BindView(R.id.shipperscore)
    TextView shipperscore;
    @BindView(R.id.jiaoyi)
    TextView jiaoyi;
    @BindView(R.id.pingjia)
    TextView pingjia;
    @BindView(R.id.show_new_old)
    RelativeLayout showNewOld;
    private String driverid = "";

    @Override
    public int getContentViewResId() {
        return R.layout.activity_driver_empty_car_detail;
    }

    @Override
    public void initView() {
        Bundle extras = getIntent().getExtras();
        driverid = extras.getString("driverid");


        setcenterTitle("空车详情");

        getGoodsDetail(driverid);
    }

    @Override
    public void leftbarclick() {
        super.leftbarclick();
        finish();
    }

    @Override
    public void initData() {

    }

    private void getGoodsDetail(String dataid) {
        OkGo.<String>get(Get_Empty_Details)
                .params("id", dataid)
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        EmptyDetailBean detailBean = GsonUtil.parseJsonWithGson(response.body(), EmptyDetailBean.class);
                        if (detailBean.getCode().equals("0")) {
                            stratPlace.setText(detailBean.getData().getLoading());
                            endPlace.setText(detailBean.getData().getUnloading());
                            carNum.setText(detailBean.getData().getVehicle_number());
                            carType.setText(detailBean.getData().getCar_info());
                            carPho.setText(detailBean.getData().getMobile());
                            carName.setText(detailBean.getData().getUsername());
                            shipperscore.setText(detailBean.getData().getScore());
                            jiaoyi.setText(String.valueOf(detailBean.getData().getTransactionsNum()));
                            pingjia.setText(String.valueOf(detailBean.getData().getEvaluateCount()));
                            commentscore.setText(detailBean.getData().getLevel());
                            if (detailBean.getData().getPhoto() != null) {
                                if (detailBean.getData().getPhoto().length() > 0) {
                                    Glide.with(DriverEmptyDetailActivity.this).load(detailBean.getData().getPhoto()).placeholder(R.mipmap.picture).into(shippername);
                                }
                            }

                        }
                    }
                });
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

}
